<!doctype html>
<html lang="zh">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="keywords" content="鱿鱼极速导航,PC冲浪网址导航,最轻量的自定义网址导航">
<meta name="description" content="鱿鱼极速导航,PC冲浪网址导航,最轻量的自定义网址导航">
<title>鱿鱼导航</title>
<link rel="shortcut icon" href="/asserts/img/favicon.ico">
<link rel="stylesheet" href="/asserts/css/bootstrap.min.css">
<link rel="stylesheet" href="/asserts/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="/asserts/layer/skin/layer.css">
<link rel="stylesheet" href="/asserts/css/style.css">
<style type="text/css">
[v-cloak]{
	display: none;
}
</style>
</head>
<body>
	<!-- 	通过代理获取天气 -->
	<div class="container" id="app">
		<div class="row">
			<div class="col-sm-9 col-xs-12">
				<div class="text-right">
					<!-- 	通过代理获取天气 -->
					<iframe id="weather" src="https://i.tianqi.com/index.php?c=code&id=12&icon=6&num=6"></iframe>
				</div>
			</div>
			<div class="col-sm-3 hidden-xs">
				<ul class="nav navbar navbar-top-links navbar-right pull-enter">
					<li class="dropdown topbar-user">
						<a data-hover="dropdown" class="dropdown-toggle">
							<img src="/asserts/img/my-icon.png" alt="" class="img-responsive img-circle">
							<span v-show="!logined">欢迎冲浪</span>
							<span v-show="logined" v-cloak>{{ nickName }}</span>
							<span class="caret"></span>
						</a>
						<ul class="dropdown-menu dropdown-user pull-right" v-if="logined">
							<li>
								<a @click.prevent="editUser" class="J_menuItem" data-index="0">
									<i class="fa fa-edit fa-fw"></i>修改信息
								</a>
							</li>
							<li>
								<a @click.prevent="editBg" class="J_menuItem" data-index="0">
									<i class="fa fa-picture-o fa-fw"></i>更换背景
								</a>
							</li>
							<li>
								<a class="J_menuItem" data-index="1" @click.prevent="eraser">
									<i class="fa fa-eraser fa-fw"></i>注销账号
								</a>
							</li>
							<li role="separator" class="divider"></li>
							<li>
								<a @click.prevent="logout" >
									<i class="fa fa-sign-out fa-fw"></i>退出登录
								</a>
							</li>
						</ul>
						<ul class="dropdown-menu dropdown-user pull-right" v-if="!logined">
							<li>
								<a data-toggle="modal" data-target="#loginModal" class="J_menuItem" data-index="0">
									<i class="fa fa-user fa-fw"></i>登录
								</a>
							</li>
							<li>
								<a data-toggle="modal" data-target="#registModal" @click="isRegist=true;" class="J_menuItem" data-index="1">
									<i class="fa fa-registered fa-fw"></i>注册
								</a>
							</li>
							<li role="separator" class="divider"></li>
							<li>
								<a @click.prevent="aboutMe">
									<i class="fa fa-info-circle fa-fw"></i>关于
								</a>
							</li>
						</ul>
					</li>
				</ul>
			</div>

			<div class="baidu-box col-sm-12">
				<form id="baidu-form" class="form-horizontal" method="get"
					action="https://www.baidu.com/s" target="_blank">
					<div class="hidden-params">
						<input type="hidden" name="tn" value="baiduimage"> <input
							type="hidden" name="ie" value="utf-8"> <input
							type="hidden" name="sc"
							value="UWd1pgw-pA7EnHc1FMfqnHRdPH03njnkPWfYPzuW5y99U1Dznzu9m1YznW63rjRLrHmd">
						<input type="hidden" name="ssl_sample" value="s_102"> <input
							type="hidden" name="srcqid" value="3016026224504065595">
						<input type="hidden" name="f" value="3"> <input
							type="hidden" name="rsp" value="0"> <input type="hidden"
							name="H123Tmp" value="nunew7">
					</div>
					<div class="form-group">
						<div class="col-lg-6 col-md-6 col-sm-6 col-xs-9 col-sm-offset-2"
							style="padding-right: 0;">
							<div class="input-group" style="padding-left: 15px;">
								<div class="input-group-btn">
									<button type="button" class="btn btn-default dropdown-toggle"
										data-hover="dropdown" aria-haspopup="true"
										aria-expanded="false">
										<span class="searchType">网页</span> &nbsp;&nbsp;<span
											class="caret"></span>
									</button>
									<ul class="dropdown-menu">
										<li><a
											href="javascript: $('#searchInput').attr('name', 'word');$('.searchType').html('网页');$('#baidu-form').attr('action','https://www.baidu.com/s');">网页</a>
										</li>
										<li><a
											href="javascript: $('#searchInput').attr('name', 'word');$('.searchType').html('图片');$('#baidu-form').attr('action','http://image.baidu.com/search/index');">图片</a>
										</li>
										<li><a
											href="javascript: $('#searchInput').attr('name', 'wd');$('.searchType').html('地图');$('#baidu-form').attr('action','https://map.baidu.com/search');">地图</a>
										</li>
										<li><a
											href="javascript: $('#searchInput').attr('name', 'kw');$('.searchType').html('贴吧');$('#baidu-form').attr('action','https://tieba.baidu.com/f');">贴吧</a>
										</li>
										<li><a
											href="javascript: $('#searchInput').attr('name', 'word');$('.searchType').html('知道');$('#baidu-form').attr('action','https://zhidao.baidu.com/search');">知道</a>
										</li>
										<li><a class="btn btn-link"
											href="https://www.baidu.com/more/" target="_blank">更多  <i class="fa fa-fw fa-angle-double-right"></i> </a></li>
									</ul>
									<button class="btn btn-default baidu-btn hidden-xs" type="button"
										onclick="location.href='https://www.baidu.com/'">
										<img alt="https://www.baidu.com/" src="/asserts/img/baidu.png">
									</button>
								</div>
								<input id="searchInput" type="text" class="form-control" v-on:keyup.enter="$('#baidu-form').submit()"
									name="word" aria-label="..." placeholder="搜就完了" v-focus>
							</div>
						</div>
						<div class="col-lg-2 col-md-2 col-sm-2 col-xs-3"
							style="padding: 0; padding-right: 15px;">
							<button type="submit" class="btn btn-primary search-btn" >百度一下</button>
						</div>
					</div>
				</form>
			</div>

			<div class="col-sm-12 col-xs-12 div-box hidden-xs">
				<div class="panel panel-info">
					<div class="panel-heading" v-if="showHeader" v-cloak>
						<div class="search-box">
			               <input type="text" placeholder="检索..." class="search-input" v-model="searchText" v-focus>
			               <div class="icon" :class="{'active': searchText!=''}" @click.prevent="searchText=''">
				               <i class="fa fa-times-circle"></i>
			               </div>
						</div>
			        </div>
					<div class="panel-body href-box" :class="{'noborderTop': myLinks.length>0}">
						<a v-for="(link,index) in myLinks" v-cloak
							class="btn btn-link col-lg-2 col-md-3 col-sm-4 col-xs-6 no-padding-left myLink"
							:class="[link.active]"
							:href="link.value" target="_blank" :name="link.name" :title="link.name"
							:index="index">
							<img class="icon-img" alt="" :src="'http://wp.yigujin.wang/favicon/get.php?url='+link.value">
							{{ link.name }}
						</a>
						<a class="btn btn-add btn-link col-lg-2 col-md-3 col-sm-4 col-xs-6" @click="add">
							<i class="fa fa-plus fa-fw"></i>添加链接
						</a>
					</div>
				</div>
			</div>

			<div class="col-sm-12 col-xs-12 div-box">
				<div class="panel panel-primary">
					<div class="panel-body href-box">
						<a v-for="link in links" v-cloak :title="link.name"
							class="btn btn-link col-lg-2 col-md-3 col-sm-4 col-xs-6 no-padding-left"
							:href="link.value" target="_blank">
							<img class="icon-img" alt="" :src="'http://wp.yigujin.wang/favicon/get.php?url='+link.value">
							{{ link.name }}</a>
					</div>
				</div>
			</div>
		</div>

		<div class="modal fade" id="myModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header ">
						<button type="button" class="close pull-right modal-close-btn"
							data-dismiss="modal" aria-hidden="true">
							<i class="fa fa-close"></i>
						</button>
						<h4 class="modal-title">
							<span v-if="index===''">添加链接</span><span v-else>修改链接</span>
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal">
							<input type="hidden" name="index" v-model="index">
							<div class="form-group" style="margin-bottom: 30px;">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									网站名称： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="text" name="name" v-model="name"
										class="form-control" placeholder="请输入网站名称" v-focus>
								</div>
							</div>
							<div class="form-group" style="margin-bottom: 30px;">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									链接地址： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<div class="input-group">
										<div class="input-group-btn">
											<button type="button" class="btn btn-default dropdown-toggle" style="margin-right: -1px;height: 34px;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span v-text="agent"></span> <span class="caret"></span></button>
											<ul class="dropdown-menu">
												<li><a @click.prevent="agent='http://'">http://</a></li>
												<li><a @click.prevent="agent='https://'">https://</a></li>
												<li role="separator" class="divider"></li>
												<li><a @click.prevent="agent=''">自定协议</a></li>
											</ul>
										</div>
										<input type="text" name="value" v-model="value" aria-label="..."
											class="form-control" placeholder="请输入链接地址，协议以输入内容为准" v-focus>
									</div>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									智能识别： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<textarea type="text" v-model="textInput" style="resize: none;"
										class="form-control text-input" placeholder="请输入网站名称和链接，以空格隔开，或直接输入链接地址" v-focus>
									</textarea>
								</div>
								<div class="col-lg-6 col-md-6 col-sm-6 col-sm-offset-3 col-md-offset-3 col-lg-offset-3" style="margin-top: 10px;">
									<button type="button" class="btn btn-danger" @click.prevent="recognize()"><i class="fa fa-link"></i> 智能识别</button>
								</div>
							</div>
						</form>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">
							<i class="fa fa-reply"></i>&nbsp; 放弃
						</button>
						<button type="button" class="btn btn-primary" @click="addLink">
							<i class="fa fa-check"></i>&nbsp; 保存
						</button>
					</div>
				</div>
			</div>
		</div>

		<div class="modal fade" id="loginModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header bg-primary">
						<h3 class="modal-title text-center ">欢迎登录</h3>
					</div>
					<div class="modal-body row">
						<form class="form-horizontal">
							<div class="form-group" style="margin-bottom: 34px;">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									账号： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="text" name="user_name" maxlength="12" v-model="user_name"
										class="form-control" placeholder="请输入账号" v-focus>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									密码： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="password" name="password" maxlength="16" v-model="password"
										class="form-control" placeholder="请输入密码" v-focus>
								</div>
							</div>
						</form>
					</div>
					<div class="modal-footer text-center">
						<div class="col-lg-4 col-md-4 col-sm-4 text-center col-lg-offset-2 col-md-offset-2 col-sm-offset-2">
							<button type="button" class="btn btn-success" data-dismiss="modal">
								<i class="fa fa-paper-plane"></i>&nbsp;&nbsp; 我再看看
							</button>
						</div>
						<div class="col-lg-4 col-md-4 col-sm-4 text-center">
							<button type="button" class="btn btn-primary" @click="login">
								<i class="fa fa-cloud"></i>&nbsp;&nbsp; 立即登录
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="modal fade" id="registModal">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header bg-primary">
						<h3 class="modal-title text-center"><span v-if="isRegist">欢迎注册</span><span v-else>修改信息</span> </h3>
					</div>
					<div class="modal-body row">
						<form class="form-horizontal">
							<div class="form-group" style="margin-bottom: 34px;">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									账号： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="text" v-model="user_name" maxlength="12"
										class="form-control" placeholder="请输入账号，4到12位字母、数字、下划线或-" v-focus>
								</div>
							</div>
							<div class="form-group" style="margin-bottom: 34px;">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									昵称： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="text" v-model="nickName" maxlength="12"
										class="form-control" placeholder="请输入昵称" v-focus>
								</div>
							</div>
							
							<div class="form-group" style="margin-bottom: 34px;" v-show="!isRegist">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									旧密码： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="password" v-model="old_password" maxlength="16" autocomplete="new-password"
										class="form-control" placeholder="请输入旧密码，若修改密码则必填" v-focus>
								</div>
							</div>
							<div class="form-group" style="margin-bottom: 34px;">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									新密码： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="password" v-model="regist_password" maxlength="16" autocomplete="new-password"
										class="form-control" placeholder="请输入密码，6到16位字母、数字、下划线" v-focus>
								</div>
							</div>
							<div class="form-group">
								<label class="col-lg-3 col-md-3 col-sm-3 control-label">
									确认密码： </label>
								<div class="col-lg-8 col-md-8 col-sm-8">
									<input type="password" v-model="regist_re_password" maxlength="16"
										class="form-control" placeholder="请再次确认密码" v-focus>
								</div>
							</div>
						</form>
					</div>
					<div class="modal-footer text-center">
						<div class="col-lg-4 col-md-4 col-sm-4 text-center col-lg-offset-2 col-md-offset-2 col-sm-offset-2">
							<button type="button" class="btn btn-success" data-dismiss="modal">
								<i class="fa fa-paper-plane"></i>&nbsp;&nbsp; 我再看看
							</button>
						</div>
						<div class="col-lg-4 col-md-4 col-sm-4 text-center">
							<button type="button" class="btn btn-primary" @click="regist" v-if="isRegist">
								<i class="fa fa-cloud"></i>&nbsp;&nbsp; 立即注册
							</button>
							<button type="button" class="btn btn-primary" @click="regist" v-if="!isRegist">
								<i class="fa fa-cloud"></i>&nbsp;&nbsp; 确认修改
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<input id="fileInput" type="file" accept="image/*" class="fileInput" onchange="fileChange('fileInput')">

	<script type="text/javascript" src="/asserts/js/configs.js"></script>
	<script type="text/javascript" src="/asserts/js/vue.min.js"></script>
	<script type="text/javascript" src="/asserts/js/vue-resource.min.js"></script>
	<script type="text/javascript" src="/asserts/js/jquery.min.js"></script>
	<script type="text/javascript" src="/asserts/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/asserts/js/BootstrapMenu.min.js"></script>
	<script type="text/javascript" src="/asserts/js/bootstrap-hover-dropdown.js"></script>
	<script type="text/javascript" src="/asserts/js/fastclick.js"></script>
	<script type="text/javascript" src="/asserts/js/upload-img.js"></script>
	<script type="text/javascript" src="/asserts/layer/layer.js"></script>
	<script type="text/javascript">
		window.addEventListener("load", function () {
			FastClick.attach(document.body);
		}, false);

		function IsPC() {
			var userAgentInfo = navigator.userAgent.toLowerCase();
			var Agents = ["android", "iphone",
				"symbianos", "windows phone",
				"ipad", "ipod"
			];
			var flag = true;
			for (var v = 0; v < Agents.length; v++) {
				if (userAgentInfo.indexOf(Agents[v]) > 0) {
					flag = false;
					break;
				}
			}
			return flag;
		}

		function createBootstrapMenu() {
			// 设置自定义链接的右键选项
			var menu = new BootstrapMenu('a.myLink', {
				//fetchElementData获取元数据
				fetchElementData: function ($rowElem) {
					var data = $rowElem;
					return data;    //return的目的是给下面的onClick传递参数
				},
				actions: [{
					name: '修改链接',
					width: 300,
					iconClass: 'fa fa-edit',
					classNames: 'my-menu',
					onClick: function (obj) {
						vm.index = $(obj).attr("index");
						vm.name = $(obj).attr("name");
						vm.agent = $(obj).attr("href").split("://")[0]+"://";
						vm.value = $(obj).attr("href").split("://")[1];
						$('#myModal').modal('toggle');
					}
				},
				{
					name: '删除链接',
					width: 300,
					iconClass: 'fa fa-remove',
					classNames: 'my-menu',
					onClick: function (obj) {
						var index = $(obj).attr("index");
						vm.delLink(index);
					}
				},
				{
					name: '取消',
					width: 300,
					iconClass: 'fa fa-reply',
					classNames: 'my-menu',
					onClick: function (obj) {
						return false;
					}
				}
				]
			});
		}
		
		function initTitle(){
			var x = 10;
	        var y = 20;
	        var newtitle = '';
	        $(".href-box .btn-link").mouseover(function (e) {
	            newtitle = this.title;
	            if(newtitle){
// 		            $(this).removeAttr("title");
		            this.title = "";
		            $('body').append('<div id="mytitle" >' + newtitle + '</div>');
		            $('#mytitle').css({
		                'left': (e.pageX + x + 'px'),
		                'top': (e.pageY + y - 80 + 'px')
		            }).show();
	            }
	        }).mouseout(function () {
// 	        	$(this).attr("title", newtitle);
	            this.title = newtitle;
	            $('#mytitle').remove();
	        }).mousemove(function (e) {
	            $('#mytitle').css({
	                'left': (e.pageX + x +10 + 'px'),
	                'top': (e.pageY + y - 60 + 'px')
	            }).show();
	        })
		}

		var userNameReg = /^[a-zA-Z0-9_-]{4,12}$/;
		var pwdReg = /^[a-zA-Z0-9_]{6,16}$/
		var vm = new Vue({
			el: '#app',
			data: {
				calendar: '',
				logined: <#if user??>true<#else>false</#if>,
				showHeader: false,
				name: '',
				value: '',
				textInput: "",
				agent: '',
				searchText: "",
				links: config.links,
				myLinks: [],
				index: '',
				isPc: IsPC(),
				user_name: '',
				password: '',
				old_password: '',
				regist_password:'',
				regist_re_password:'',
				isRegist: true,
				nickName: '<#if user?? && user.nickName??>${user.nickName!}</#if>',
				bgUrl: "${bgUrl!'/asserts/img/beuty.jpg?1=1&p=1.78'}"
			},
			watch: {
				myLinks(){
					this.showHeader = this.myLinks.length>0;
				},
				searchText(){
					if(this.searchText){
						for(var i in this.myLinks){
							var link = this.myLinks[i];
							if(link.name.toLowerCase().indexOf(this.searchText.toLowerCase())>-1){
								link.active = 'active'
							}else{
								Vue.delete(link, "active");
							}
						}
					}else{
						for(var i in this.myLinks){
							Vue.delete(this.myLinks[i], "active");
						}
					}
				}
			},
			directives: {
				"focus": {
					inserted: function (el) {
						if (IsPC()) {
							el.focus();
							$(el).mouseover(function () {
								el.focus();
								$(el).select();
							})
						}
					}
				}
			},
			methods: {
				saveMyLinks(myLinks) {
					var links = JSON.stringify(myLinks);
					this.$http.post("/link/saveMyLinks", {links: links}, {"emulateJSON": true}).then(function(data){
						if(data.body.code){
							
							layer.msg("操作成功！", {icon: 1});
							this.myLinks = myLinks;
						}else{
							layer.msg(data.body.msg, {icon: 2})
						}
					})
				},
				getMyLinks(links) {
					if(links!='' && links!=null){
						return (JSON.parse(links));
					}else{
						return [];
					}
				},
				add(){
					if(!this.logined){
						layer.msg("请先登录", {icon: 5})
					}else{
						this.index='';this.name='';this.value='';
						$('#myModal').modal('toggle');					
					}
				},
				getAllowStr(str, allowType){
					if(allowType){
						for(var index in allowType){
							var type = allowType[index];
							if(str.indexOf(type)==0){
								return str;
							}
						}
					}
					return this.agent + str;
				},
				getTitleByUrl(url){
					var _this = this;
					return new Promise(function(resolve, reject){
						_this.$http.post("https://api.uomg.com/api/get.title", {url: url}, {"emulateJSON": true}).then(function(res){
							
							if(res && res.body.title){
								resolve(res.body.title);
							}else{
								reject();
							}
						})
					})
				},
				recognize(){
					var urlRegexp = /(http|https):/;
					if(this.textInput){
						if(this.textInput.indexOf(" ")>-1){
							// 如果有空格
							var text = this.textInput.split(" ");
							if(text.length>1){
								for(var i=0;i<text.length;i++){
									if(urlRegexp.test(text[i])){
										this.name = text[Math.abs(i-1)];
										this.value = text[i];
									}
								}
							}
						}else if(urlRegexp.test(this.textInput)){
							var _this = this;
							this.value = this.textInput;
							this.getTitleByUrl(this.value).then(function(title){								
								_this.name = title;
							});
						}
					}else {
						layer.msg("请输入网站名称和链接，并以空格隔开！或直接输入链接地址！",{icon: 2});
					}
				},
				addLink() {
					this.searchText = "";
// 					以用户输入的协议为准，没有协议则添加前面选择过的协议
					var val = this.getAllowStr(this.value, ["http://","https://"]);
					if (this.index == '') {
						/* 新增 */
						this.myLinks.push({
							name: this.name,
							value: val
						});
					} else {
						/* 修改 */
						this.myLinks.splice(this.index, 1, {
							name: this.name,
							value: val
						});
						this.index == '';
					}
					this.saveMyLinks(this.myLinks);
					$('#myModal').modal('toggle');
				},
				delLink(index) {
					this.myLinks.splice(index, 1);
					this.saveMyLinks(this.myLinks);
				},
				regist(){
					var userName = this.user_name;
					var nickName = this.nickName;
					var oldPwd = this.old_password;
					var password = this.regist_password;
					var repwd = this.regist_re_password;
					var regist = 1;
					
					if(this.isRegist){
						regist = 1;
						if(!userNameReg.test(userName)){
							layer.msg("请输入格式正确的账号！",{icon: 2});
							return;
						}
						
						if(nickName.length<1){
							layer.msg("请输入昵称！",{icon: 2});
							return;
						}
						
						if(!pwdReg.test(password)){
							layer.msg("请输入格式正确的新密码！",{icon: 2});
							return;
						}else if(password != repwd){
							layer.msg("您的新密码与确认密码不一致！", {icon: 2});
							return;
						}
					}else{
						regist = -1;
						if(userName!=''){
							if(!userNameReg.test(userName)){
								layer.msg("请输入格式正确的账号！",{icon: 2});
								return;
							}
						}
						
						if(pwdReg.test(oldPwd)){
							if(password != repwd){
								layer.msg("您的新密码与确认密码不一致！", {icon: 2});
								return;
							}else if(password != '' && !pwdReg.test(password)){
								layer.msg("请输入格式正确的新密码！",{icon: 2});
								return;
							}
						}
					}
					
					this.$http.post('/user/register', {userName: userName, nickName: nickName, password: password, regist: regist, oldPwd: oldPwd}, {"emulateJSON": true}).then(function(data){
						if(data.body.code){
							layer.msg(data.body.msg, {icon: 1});
							$('#registModal').modal('toggle');
							setTimeout(()=>{
								window.location.reload();
							},1000)
						}else{
							layer.msg(data.body.msg, {icon: 2})
						}
					})
				},
				login(){
					var userName = this.user_name;
					var pwd = this.password;
					if(!userNameReg.test(userName)){
						layer.msg("请输入格式正确的账号！",{time: 5000,icon: 2});
						return;
					}
					
					if(!pwdReg.test(pwd)){
						layer.msg("请输入格式正确的密码！",{time: 5000,icon: 2});
						return;
					}
					
					this.$http.post('/user/login', {userName: userName, password: pwd}, {"emulateJSON": true}).then(function(data){
						if(data.body.code){
							layer.msg(data.body.msg, {icon: 1});
							$('#loginModal').modal('toggle');
							this.bgUrl = ((data.body.data.user.bgUrl==''||data.body.data.user.bgUrl==null)?'/asserts/img/beuty.jpg?1=1&p=1.78':data.body.data.user.bgUrl);
							this.bgAdaption();
							this.myLinks = this.getMyLinks(data.body.data.links);
							this.user_name = data.body.data.user.userName;
							this.nickName = data.body.data.user.nickName;
							this.logined = true;
						}else{
							layer.msg(data.body.msg, {time: 5000,icon: 2})
						}
					})
				},
				editBg(){
					return $('#fileInput').click();
				},
				logout(){
					this.$http.get('/user/logout').then(function(data){
						if(data.body.code){
							layer.msg(data.body.msg, {icon: 1});
							setTimeout(()=>{
								window.location.reload();
							},0)
						}else{
							layer.msg(data.body.msg, {time: 5000,icon: 2})
						}
					})
				},
				eraser(){
					layer.confirm('注销后本站会将您的所有相关信息做物理删除，不可找回，您还要注销这个账号吗？', {
						btn: ['是的','取消'],
						title: '警告'
					}, function(){
						vm.$http.get('/user/eraser').then(function(data){
							if(data.body.code){
								layer.msg(data.body.msg, {icon: 1});
								setTimeout(()=>{
									window.location.reload();
								},2000)
							}else{
								layer.msg(data.body.msg, {icon: 2})
							}
						})
					}, function(){
						layer.msg('刚才好惊险哦！', {
							time: 5000,
							btn: ['下不为例'],
							icon: 6
						});
					});
				},
				editUser(){
					$('#registModal').modal('toggle');
					this.isRegist = false;
				},
				aboutMe(){
					//询问框
					layer.confirm('我认为这是迄今为止最良心的导航页，这里没有多余的广告，只有恰到好处的私人订制和打了鸡血的加载速度。', {
						title:'关于',btn: ['再看看','同意'],icon:6
					}, function(){
						layer.msg('没错，我想这就是你一直想要的，冲浪就冲我来！', {icon: 6});
					}, function(){
						layer.msg('谢谢你的支持！', {
							icon: 1,
							time: 15000, //15s后自动关闭
							btn: ['朕知道了']
						});
					});
				},
				pulse(){
				    // 登录后每5分钟脉冲一次防止会话过期
					setInterval(function() {
						if(vm.logined){vm.$http.get('/pulse')}
				    }, 1000*60*5)
				},
				bgAdaption(){
					$("html").css("background-image","url("+ this.bgUrl +")");
					if(this.bgUrl.indexOf('&p=') > -1){
						var prop = this.bgUrl.substr(this.bgUrl.indexOf('&p=')+3);
						var width = $(window).width(),height = $(window).height();
						if(parseFloat(prop) > parseFloat((width/height).toFixed(2))){
							$("html").css("background-size","auto 100%");
						}else{
							$("html").css("background-size","100% auto");
						}
					}
				}
			},
			created() {
				this.myLinks = this.getMyLinks('${links!}');
				$("html").css("background-image","url(${bgUrl!'/asserts/img/beuty.jpg?1=1&p=1.78'})");
				this.bgAdaption();
			},
			mounted() {
				if (this.isPc) {
					createBootstrapMenu();
					this.pulse();
				}
				initTitle();
			},
			updated(){
				initTitle();
			}
		})
		
// 		使用FileUpload对象进行文件上传
		function fileChange(fileId){
			var upload = new FileUpload();
			var loadIndex = layer.load(2, {
				shade: [0.4, '#000']
			});
			
			upload.fileChange(function(data){
				layer.close(loadIndex);
				if(data.code){
//					设置背景图
					vm.bgUrl = data.data.fileUrl;
					vm.bgAdaption();
					layer.msg(data.msg, {icon: 1});
				}else{
					layer.msg(data.msg, {icon: 2});
				}
			},
			function(process){
				console.log("上传进度 "+process);
			},
			function(errMsg){
				layer.close(loadIndex);
				layer.msg(errMsg, {icon: 2});
			})
		}
		
		$(window).resize(function(){
			vm.bgAdaption();
		})
	</script>
</body>
</html>